package cn.dkk.structure_design.decorator;

import cn.dkk.structure_design.decorator.pojo.FastFood;
import cn.dkk.structure_design.decorator.pojo.FireRice;

/**
 * @author dkk
 * @date 2022/7/10
 * @desc
 */
public class Test {
    public static void main(String[] args) {
        FastFood food=new FireRice();
        System.out.println(food.getDesc()+" "+food.cost()+"元");

        food=new Egg(food);
        System.out.println(food.getDesc()+" "+food.cost()+"元");

        // TODO 此处有bug,第二次赋值装饰者实现类会覆盖原有的实现类的属性
        food=new Egg(food);
        System.out.println(food.getDesc()+" "+food.cost()+"元");

        food=new Bacon(food);
        System.out.println(food.getDesc()+" "+food.cost()+"元");
    }
}
